﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Infinitus.Mail.Core.Configuration
{
    public class AdClientConfiguration : ConfigurationSection
    {
        public const string DOMAIN = "domain";
        public const string DC_FQDN = "dcFQDN";
        public const string DEPARTMENT_ROOT_OU_PATH = "departmentRootOUPath";
        public const string GROUP_ROOT_OU_PATH = "groupRootOUPath";
        public const string EXCHANGE_SERVER_FQDN = "exchangeServerFQDN";
        public const string HOSTING_CONFIG_PROGRAM_ID = "hostingConfigProgramId";
        public const string HOSTING_CONFIG_OFFER_ID = "hostingConfigOfferId";
        public const string HOSTING_CONFIG_LOCATION = "hostingConfigLocation";
        public const string EMAIL_DOMAIN = "emailDomain";
        public const string LOGIN_NAME = "loginName";
        public const string PASSWORD = "password";

        public static AdClientConfiguration Config
        {
            get
            {
                AdClientConfiguration config = ConfigurationManager.GetSection("adClientConfig") as AdClientConfiguration;
                return config;
            }
        }

        [ConfigurationProperty(DOMAIN, IsRequired = true)]
        public string Domain
        {
            get
            {
                return this[DOMAIN] as string;
            }
        }

        [ConfigurationProperty(DC_FQDN, IsRequired = true)]
        public string DcFQDN
        {
            get
            {
                return this[DC_FQDN] as string;
            }
        }

        [ConfigurationProperty(DEPARTMENT_ROOT_OU_PATH, IsRequired = true)]
        public string DepartmentRootOUPath
        {
            get
            {
                return this[DEPARTMENT_ROOT_OU_PATH] as string;
            }
        }

        [ConfigurationProperty(GROUP_ROOT_OU_PATH, IsRequired = true)]
        public string GroupRootOUPath
        {
            get
            {
                return this[GROUP_ROOT_OU_PATH] as string;
            }
        }

        [ConfigurationProperty(EXCHANGE_SERVER_FQDN, IsRequired = true)]
        public string ExchangeServerFQDN
        {
            get
            {
                return this[EXCHANGE_SERVER_FQDN] as string;
            }
        }

        [ConfigurationProperty(LOGIN_NAME, IsRequired = true)]
        public string LoginName
        {
            get
            {
                return this[LOGIN_NAME] as string;
            }
        }

        [ConfigurationProperty(PASSWORD, IsRequired = true)]
        public string Password
        {
            get
            {
                return this[PASSWORD] as string;
            }
        }

        [ConfigurationProperty(HOSTING_CONFIG_PROGRAM_ID, DefaultValue="HostingSample", IsRequired = true)]
        public string HostingConfigProgramId
        {
            get
            {
                return this[HOSTING_CONFIG_PROGRAM_ID] as string;
            }
        }

        [ConfigurationProperty(HOSTING_CONFIG_OFFER_ID, DefaultValue = "2", IsRequired = true)]
        public int HostingConfigOfferId
        {
            get
            {
                return Convert.ToInt32(this[HOSTING_CONFIG_OFFER_ID]);
            }
        }

        [ConfigurationProperty(HOSTING_CONFIG_LOCATION, DefaultValue = "zh-cn", IsRequired = true)]
        public string HostingConfigLocation
        {
            get
            {
                return this[HOSTING_CONFIG_LOCATION] as string;
            }
        }

        [ConfigurationProperty(EMAIL_DOMAIN, IsRequired = true)]
        public string EmailDomain
        {
            get
            {
                return this[EMAIL_DOMAIN] as string;
            }
        }

    }
}
